<?php
/**
 *
 * (model)
 */
namespace App\Models\SalesReportLT;

use App\Util\User;
use Illuminate\Database\Eloquent\Model;

class PaymentTSSummary extends Model
{
    protected $table = 'lt_sr_payment_seller';

    protected $guarded = [];

    public $timestamps = false;

    public static $_basic = [
        'seller' => ['title' => '销售','sumField' => false,'per' => false]
    ];

    public static function headersField(): array
    {
        return self::$_basic + PaymentCNSummary::$_common;
    }

    //数值+占比
    public static function getDownloadData($re): \Generator
    {
        foreach ($re as $row){
            yield self::getDataBasic($row) + PaymentCNSummary::getNumDataCommon($row);
            yield self::getDataBasic($row) + PaymentCNSummary::getPerDataCommon($row);
        }
    }
    //数值
    public static function getDownloadNumData($re): \Generator
    {
        foreach ($re as $row){
            yield self::getDataBasic($row) + PaymentCNSummary::getNumDataCommon($row);
        }
    }
    //占比
    public static function getDownloadPerData($re): \Generator
    {
        foreach ($re as $row){
            yield self::getDataBasic($row) + PaymentCNSummary::getPerDataCommon($row);
        }
    }

    public static function getDataBasic($row): array
    {
        return [
            User::getUsernameById($row->seller_id)
        ];
    }
}
